﻿<%@ Page Title="企划订单量计算" Language="C#" MasterPageFile="~/master/m.master" %>

<script runat="server"></script>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="Server">
    <link href="../assets/css/plugins/footable/footable.core.css" rel="stylesheet">
    <link href="../assets/css/shelf/base.css" rel="stylesheet">
    <link href="../assets/css/plugins/webuploader/webuploader.css" rel="stylesheet" />
    <link href="../assets/img/validate/validate.css" rel="stylesheet">
    <link href="../assets/css/plugins/iCheck/customsmall.css" rel="stylesheet" />
    <link href="../assets/css/plugins/stepper/stepper.widget.css" rel="stylesheet" />
    <%--<link href="../assets/css/plugins/boxdrop/boxDrop.css" rel="stylesheet" />--%>

    <style type="text/css">
        .system-box .right-side {
            width: 98%;
        }

        .condition, .condition-title {
            border-bottom: 1px solid #dfdfdd;
        }

        #tbMinChiMa td {
            text-align: center;
        }

            #tbMinChiMa td input {
                text-align: center;
                width: 100%;
            }

        .form-group label {
            max-width: 70px;
            margin-left: 5px;
            padding-left: 1px;
            padding-right: 1px;
        }

        #myTbTr td input {
            padding-left: 2px;
            padding-right: 2px;
        }

        @media (min-width: 750px) {
            .modal-dialog {
                width: 750px;
            }

            .footable {
                border-bottom: 1px solid #dfdfdd;
                border-left: 1px solid #dfdfdd;
            }

                .footable th,
                .footable td {
                    border-top: 1px solid #dfdfdd;
                    border-right: 1px solid #dfdfdd;
                    text-align: center;
                }

            .tb-head-container {
                padding-right: 6px;
                background: #fff;
            }

            .tb-body-container {
                overflow-x: hidden;
                padding-right: 0px;
                background: #fff;
            }
            /*所有表格行高缩小*/
            .table > tbody > tr > td, .table > tbody > tr > th, .table > tfoot > tr > td, .table > tfoot > tr > th, .table > thead > tr > td, .table > thead > tr > th {
                padding: 1px !important;
            }
        }
    </style>

</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="main" runat="Server">
    <div class="system-box">
        <div class="right-side">
            <div class="btns-container">
                <div class="modal inmodal" id="addWindow" tabindex="-1" role="dialog" aria-hidden="true">
                    <div class="modal-dialog">
                        <div class="modal-content animated bounceInRight">
                            <div class="modal-header">
                                <span class="editTitle"></span>
                                <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span> <span class="sr-only">关闭</span> </button>
                            </div>
                            <div id="message" style="display: none"></div>
                            <div class="modal-body clearfix">
                                <form class="form-horizontal">
                                    <div class="form-group">
                                        <label for="CompanyID" class="col-sm-2 control-label">公司编码</label>
                                        <div class="col-sm-10">
                                            <input type="text" id="CompanyID" name="CompanyID" placeholder="" class="form-control" readonly="readonly" value="" />
                                        </div>
                                    </div>
                                    <div class="form-group">
                                        <label for="shopSearch" class="col-sm-2 control-label">店&nbsp;&nbsp;铺:</label>
                                        <div class="col-sm-10">
                                            <input type="text" id="shopSearch" name="shopSearch" placeholder="请输入店铺代码或名称" datacol="yes" err="店铺" checkexpession="NotNull" class="form-control required" />
                                        </div>
                                    </div>

                                    <div class="form-group">
                                        <label for="ShopCode" class="col-sm-2 control-label">店铺编号:</label>
                                        <div class="col-sm-10">
                                            <input type="text" id="ShopCode" name="ShopCode" placeholder="" datacol="yes" err="店铺编号" checkexpession="NotNull" class="form-control required" readonly />
                                            <input type="text" id="OldShopCode" name="OldShopCode" placeholder="" datacol="yes" err="店铺编号" class="hide" readonly />
                                        </div>
                                    </div>

                                    <div class="form-group">
                                        <label for="ShopID" class="col-sm-2 control-label">店铺内码:</label>
                                        <div class="col-sm-10">
                                            <input type="text" id="ShopID" name="ShopID" placeholder="" datacol="yes" err="店铺内码" class="form-control" readonly />
                                        </div>
                                    </div>

                                    <div class="form-group">
                                        <label for="MaterialID" class="col-sm-2 control-label">货号:</label>
                                        <div class="col-sm-8">
                                            <input type="text" id="MaterialID" name="MaterialID" placeholder="" datacol="yes" err="货号" checkexpession="NotNull" class="form-control required" />
                                            <input type="text" id="OldMaterialID" name="OldMaterialID" placeholder="" datacol="yes" err="货号" class="hide" />
                                        </div>
                                        <div class="col-sm-2">
                                            <input type="button" id="SearchSize" name="SearchSize" placeholder="" datacol="yes" value="查询尺码" class="form-control" />
                                        </div>
                                    </div>

                                    <div class="form-group">
                                        <label for="TotalQty" class="col-sm-2 control-label">SKC数量:</label>
                                        <div class="col-sm-10">
                                            <input type="number" id="TotalQty" name="TotalQty" placeholder="请输入SKC数量" datacol="yes" checkexpession="NotNull" err="SKC数量" maxlength="6" class="form-control required" />
                                        </div>
                                    </div>
                                    <div class="form-group">
                                        <label for="tbMinChiMa" class="col-sm-2 control-label">最低深度:</label>
                                        <div class="col-sm-12">
                                            <input id="OldSizeLength" type="hidden" />
                                            <table id="tbMinChiMa">
                                                <thead>
                                                    <tr id="myThTr">
                                                        <td></td>
                                                    </tr>
                                                </thead>
                                                <tbody>
                                                    <tr id="myTbTr">
                                                        <td></td>
                                                    </tr>
                                                </tbody>
                                            </table>
                                        </div>
                                    </div>
                                </form>
                            </div>
                            <div class="modal-footer">
                                <button type="button" id="addModuleBtn" class="btn btn-primary">保存</button>
                                <button type="button" id="closeAddBox" class="btn btn-white" data-dismiss="modal">关闭</button>
                            </div>
                        </div>
                    </div>
                </div>
            </div>

            <div class="condition">
                <label>店铺</label>
                <input type="text" placeholder="店铺代码或名称" id="search-store" data-value="" class="form-control input-w170" />
                <label>货号</label>
                <input id="search_materialID" class="form-control input-w170" placeholder="货号" />
            </div>

            <div class="right-content-box">
                <div class="ibox-content">
                    <table class="footable table table-stripped">
                        <thead></thead>
                        <tbody id="pageList"></tbody>
                    </table>
                </div>
            </div>

            <div class="pageControl"></div>
        </div>
    </div>

</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="footer" runat="Server">
    <script src="../assets/js/jquery-ui-1.10.4.min.js"></script>
    <script src="../assets/img/validate/learunui-validator.js"></script>
    <script src="../assets/js/page/pageControl.js"></script>
    <script src="../assets/js/page/rScroll.js"></script>
    <script src="../assets/js/page/tableControl.js"></script>
    <script src="../assets/js/plugins/webuploader/webuploader.min.js"></script>
    <script src="../assets/js/framework.js"></script>
    <script src="../assets/js/plugins/bootstrap-typeahead/bootstrap-typeahead.js"></script>
    <script src="../assets/js/plugins/iCheck/icheck.min.js"></script>
    <script src="../assets/js/plugins/iCheck/icheckAll.js"></script>
    <script src="../assets/js/plugins/stepper/stepper.widget.js"></script>
    <%--<script src="../assets/js/plugins/boxdrop/jquery.boxdrop.js"></script>--%>
    <script>
        $('document').ready(function () {
            //模块ID
            var ModuleID = Y.getUrlParam("ModuleID");
            //当前页数
            var page = 1;
            commonUtil.loadBtnList(ModuleID, function () {
                $('#editBtn').attr("disabled", "disabled");
                //$('#deleteBtn').attr("disabled", "disabled");
                rScroll();
            });

            var dataList = [];

            IsCreate = true;

            shopCode = '';
            materialID = '';
            sizeLength = '';
            sizeID = '';

            flag = '';
            //处理表头
            if ($('.footable thead').children().size() == 0) {
                tableControl.initThead('.footable',
                    [
                        {
                            trClass: '',
                            children: [
                                { tdText: '', c: 0, r: 0, tdHtml: '<input type="checkbox" id="checkAllPlan" />', tdId: '', tdClass: 'diy-td-w30' },
                                { tdText: '公司代码', c: 0, r: 0, tdHtml: '', tdId: '', tdClass: 'hide' },
                                { tdText: '店铺内码', c: 0, r: 0, tdHtml: '', tdId: '', tdClass: 'hide' },
                                { tdText: '店铺编号', c: 0, r: 0, tdHtml: '', tdId: '', tdClass: 'diy-td-w50' },
                                { tdText: '店铺名称', c: 0, r: 0, tdHtml: '', tdId: '', tdClass: 'diy-td-w150' },
                                { tdText: '货号', c: 0, r: 0, tdHtml: '', tdId: '', tdClass: 'diy-td-w100' },
                                { tdText: 'SKC数量', c: 0, r: 0, tdHtml: '', tdId: '', tdClass: 'diy-td-w50' },
                                { tdText: '尺码长度', c: 0, r: 0, tdHtml: '', tdId: '', tdClass: 'diy-td-w50' },
                                { tdText: '尺码名称', c: 0, r: 0, tdHtml: '', tdId: '', tdClass: 'diy-td-w50' },
                                { tdText: '最低深度', c: 0, r: 0, tdHtml: '', tdId: '', tdClass: 'diy-td-w50' },
                                { tdText: '数量', c: 0, r: 0, tdHtml: '', tdId: '', tdClass: 'diy-td-w50' },
                                { tdText: '标识', c: 0, r: 0, tdHtml: '', tdId: '', tdClass: 'hide' }
                            ]
                        }
                    ]);
            }

            var getSizeList = function (MaterialID, ShopCode) {
                Y.API2('PlanningOrderQuantity', "GetSizeList",
                    {
                        MaterialID: MaterialID,
                        ShopCode: ShopCode
                    },
                    function (data) {
                        layer.closeAll('dialog');
                        if (data.Success == false) {
                            swal(data.Message, '', 'error');
                        } else {
                            $('tr#myTbTr').html('');
                            data.map(function (item, i) {
                                var thtd = "";
                                var trtd = "";

                                item.map(function (row, j) {
                                    if (i == 0) {
                                        thtd += '<td>' + row.SizeName + '</td>';
                                    }
                                    trtd += '<td>' + '<input class="td1 form-control" readonly data-id="' + row.SizeID
                                        + '" data-modelid="' + row.ModelID
                                        + '" data-name="' + row.SizeName
                                        + '" data-sizeTypeFlag="' + row.SizeTypeFlag
                                        + '" value="' + row.MinQty + '"/>' + '</td>';
                                    if (j == item.length - 1) {
                                        trtd = '<td class="text-center">' + '<input type="radio" name="size-length" style="width:20px" class="td1" value="' + row.SizeLength + '" />' + row.SizeLength + '</td>' + trtd;
                                    }
                                });
                                if (i == 0) {
                                    thtd = '<td class="diy-td-w100">尺码长度</td>' + thtd;
                                    $('#myThTr').html('' + thtd + '');
                                }

                                $('tr#myTbTr:last').after('<tr id="myTbTr">' + trtd + '</tr>');
                            });

                            //如果是编辑状态,就选中原来的值
                            if ($("#OldSizeLength").val() != undefined && $("#OldSizeLength").val().length > 0) {
                                $("input[type=radio][value=" + $("#OldSizeLength").val() + "]").attr("checked", "true");
                                //如果检测到是导入的已经计算过的,就不让修改尺码长度
                                if (flag != undefined && flag == 1) {
                                    $("input[type=radio]").attr("disabled", "disabled");
                                }
                            }
                            //如果是新建状态,就默认选中第一个
                            else {
                                $("input[type=radio]:first").attr("checked", "true");
                            }

                        }
                    });
            };

            var pageList = [];
            //获取列表
            var loadList = function () {
                $('#editBtn').attr('disabled', 'disabled');
                //$('#deleteBtn').attr('disabled', 'disabled');

                shopCode = '';
                materialID = '';
                sizeID = '';

                pageControl.init('PlanningOrderQuantity', 'GetList', {
                    keys: $('#search-store').val().trim().replace(/'/g, ''),
                    materialId: $('#search_materialID').val(),
                    Page: page,
                    Size: 50,
                    needLayer: true,
                    alwaysCallBack: function () {
                        $('#pageList').empty();
                    }
                }, function (result) {
                    pageList = [];
                    page = result.page;
                    var tBody = [];
                    if (!Y.checkNull(result.data)) {
                        if (result.data.Items.length > 0) {
                            dataList = result.data.Items;
                            var IsEmpty = '0';
                            result.data.Items.map(function (items, i) {
                                //pageList.push(item);
                                items.map(function (item, j) {
                                    var tempChild = [];
                                    if (j == 0) {
                                        tempChild = [
                                            {
                                                tdText: '',
                                                c: 0,
                                                r: items.length,
                                                tdHtml:
                                                '<input type="checkbox" class="checkPlan" data-index="' +
                                                i +
                                                '" />',
                                                tdId: '',
                                                tdClass: ''
                                            },
                                            {
                                                tdText: '',
                                                c: 0,
                                                r: items.length,
                                                tdHtml: '<span style="display:inline-block; width:100px;">' +
                                                (item.CompanyID || IsEmpty) +
                                                '</span>',
                                                tdId: '',
                                                tdClass: 'hide CompanyID'
                                            },
                                            {
                                                tdText: '',
                                                c: 0,
                                                r: items.length,
                                                tdHtml: '<span style="display:inline-block; width:100px;">' +
                                                (item.ShopID || IsEmpty) +
                                                '</span>',
                                                tdId: '',
                                                tdClass: 'hide ShopID'
                                            },
                                            {
                                                tdText: '',
                                                c: 0,
                                                r: items.length,
                                                tdHtml: ((item.Flag == 1) ? '<i class="fa fa-lightbulb-o"></i>' : '') + '<span style="display:inline-block; width:50px">' +
                                                (item.ShopCode || IsEmpty) +
                                                '</span>',
                                                tdId: '',
                                                tdClass: 'ShopCode'
                                            },
                                            {
                                                tdText: '',
                                                c: 0,
                                                r: items.length,
                                                tdHtml: '<span style="display:inline-block; width:150px;">' +
                                                (item.ShopName || IsEmpty) +
                                                '</span>',
                                                tdId: '',
                                                tdClass: 'ShopName'
                                            },
                                            {
                                                tdText: '',
                                                c: 0,
                                                r: items.length,
                                                tdHtml: '<span style="display:inline-block; width:100px;">' +
                                                (item.MaterialID || IsEmpty) +
                                                '</span>',
                                                tdId: '',
                                                tdClass: 'MaterialID'
                                            },
                                            {
                                                tdText: '',
                                                c: 0,
                                                r: items.length,
                                                tdHtml: '<span style="display:inline-block; width:50px;">' + (item.TotalQty || IsEmpty) + '</span>',
                                                tdId: '',
                                                tdClass: 'TotalQty'
                                            },
                                            {
                                                tdText: '',
                                                c: 0,
                                                r: items.length,
                                                tdHtml: '<span style="display:inline-block; width:50px;">' + (item.SizeLength || IsEmpty) + '</span>',
                                                tdId: '',
                                                tdClass: 'SizeLength'
                                            }
                                        ];
                                    }
                                    tempChild.push({
                                        tdText: '',
                                        c: 0,
                                        r: 0,
                                        tdHtml: '<span style="display:inline-block; width:100px;">' + (item.SizeID || IsEmpty) + '</span>',
                                        tdId: '',
                                        tdClass: 'hide SizeID'
                                    });
                                    tempChild.push({
                                        tdText: '',
                                        c: 0,
                                        r: 0,
                                        tdHtml: '<span style="display:inline-block; width:50px;">' + (item.SizeName || IsEmpty) + '</span>',
                                        tdId: '',
                                        tdClass: 'SizeName'
                                    });
                                    tempChild.push({
                                        tdText: '',
                                        c: 0,
                                        r: 0,
                                        tdHtml: '<span style="display:inline-block; width:100%;">' + (item.SizeMinQty || IsEmpty) + '</span>',
                                        tdId: '',
                                        tdClass: 'SizeMinQty'
                                    });
                                    tempChild.push({
                                        tdText: '',
                                        c: 0,
                                        r: 0,
                                        tdHtml: '<span style="display:inline-block; width:50px;">' + (item.Qty || IsEmpty) + '</span>',
                                        tdId: '',
                                        tdClass: 'Qty'
                                    });
                                    tempChild.push({
                                        tdText: '',
                                        c: 0,
                                        r: 0,
                                        tdHtml: '<span style="display:inline-block; width:100%;" data-shopcode="' + item.ShopCode + '" data-materialid="' + item.MaterialID + '" data-sizelength="' + item.SizeLength + '">' + (item.Flag || IsEmpty) + '</span>',
                                        tdId: '',
                                        tdClass: 'Flag hide'
                                    });
                                    var tempTr = {
                                        trClass: (i % 2 == 0 ? 'gradeX footable-even' : 'gradeX footable-odd') + ' '
                                        + item.ShopID + '_'
                                        + item.MaterialID + '_'
                                        + item.TotalQty + '_'
                                        + item.SizeCodeType + '_'
                                        + item.SizeLength,
                                        children: tempChild
                                    };
                                    tBody.push(tempTr);
                                });
                            });
                        }
                        rScroll();
                    }
                    tableControl.initTbody('.footable', (tBody.length > 0 ? tBody : null), 13, null);
                    //选择全部插件
                    $(".footable").icheckAll({
                        checkObj: ".checkPlan",//表格下面的选择控件对象 选择器
                        checkAllObj: "#checkAllPlan",//全选 选择器
                        clickoutBoxCheck: false,//点击行 不选中
                        checkboxMargin: "4px 0 0 0 "//上右下左
                    });
                });
            }

            var resetInput = function () {
                $("#shopSearch").val("");
                $("#ShopCode").val("");
                $("#ShopID").val("");
                $("#MaterialID").val("");
                $("#TotalQty").val("");
                var data = sessionStorage.getItem('login-info');
                var d = $.parseJSON(data);
                if (!Y.checkNull(d.CompanyID))
                    $('#CompanyID').val(d.CompanyID);

                $('#myThTr').html('<td></td>');
                $('tr#myTbTr').html('<td></td>');
            };


            //选中记录
            $('#pageList').on('click', 'tr', function () {
                shopCode = $(this).find('.Flag span').attr("data-shopcode");
                materialID = $(this).find('.Flag span').attr("data-materialid");
                sizeLength = $(this).find('.Flag span').attr("data-sizelength");
                sizeID = $(this).find('.SizeID').text();
                flag = $(this).find('.Flag').text();
                if (!Y.checkNull(shopCode) && !Y.checkNull(materialID) && !Y.checkNull(sizeLength)) {
                    $('#editBtn').removeAttr('disabled');
                }

                $('.footable tr').removeClass('check');

                var trClass = $(this).attr("class");
                trClass = trClass.replace(/gradeX /, "");
                trClass = trClass.replace(/footable-even /, "");
                trClass = trClass.replace(/footable-odd /, "");
                trClass = '.' + trClass;
                $(trClass).addClass("check");

            });

            //自动填充(商店)
            $('#shopSearch').typeahead({
                source: function (query, process) {
                    var parameter = { query: query };
                    $('#ShopName').val('');
                    $('#ShopCode').val('');
                    $('#ShopID').val('');
                    Y.API2('DwShop', 'GetShopList', {
                        Keys: $('#shopSearch').val()
                    }, function (data) {
                        if (data.Success == false) {
                            swal(data.Message, '', 'error');
                        } else {
                            var results = data.map(function (item) {
                                return JSON.stringify(item);
                            })
                            process(results);
                        }
                    });
                },
                highlighter: function (item) {
                    var item = JSON.parse(item);
                    return '名称：' + item.ShopName + '　编号：' + item.ShopCode;
                },
                updater: function (item) {
                    var item = JSON.parse(item);
                    $('#ShopName').val(item.ShopName);
                    $('#ShopCode').val(item.ShopCode);
                    $('#ShopID').val(item.ShopID);
                    return item.ShopName;
                }
            });

            //查询按钮
            $('.btns-container').on('click', '#btn-search', function () {
                page = 1;
                loadList();
            });

            //新增按钮
            $('.btns-container').on('click', '#addBtn', function () {
                $('.editTitle').text('新增企划订单量计算');
                $('#addModuleBtn').show();
                IsCreate = true;
                $("#shopSearch").removeAttr('readonly');
                $("#TotalQty").removeAttr('readonly');

                resetInput();
            });

            //编辑按钮
            $('.btns-container').on('click', '#editBtn', function () {

                //swal('导入计算过的企划订单量不允许修改', '', 'error');
                //return false;

                $('.editTitle').text('编辑企划订单量计算');
                $('#addModuleBtn').show();
                resetInput();
                IsCreate = false;
                loadDetail(shopCode, materialID, sizeID, sizeLength);
            });

            //删除按钮
            commonUtil.initDeleteBtnEvent({
                callBack: function () {
                    submitList = [];
                    $(".footable").find('.checked').each(function () {
                        var ShopCode = $(this).parents("td").siblings(".ShopCode").text();
                        var MaterialID = $(this).parents("td").siblings(".MaterialID").text();
                        submitList.push({
                            ShopCode: ShopCode,
                            MaterialID: MaterialID,
                        });
                    });
                    if (submitList.length == 0) {
                        swal('请选择要删除的项');
                        return false;
                    }
                    console.table(submitList);
                    Y.API2('PlanningOrderQuantity', 'Remove',
                        {
                            List: submitList
                        }
                        , function (data) {
                            layer.closeAll('dialog');
                            if (data.Success == false) {
                                swal('删除失败', data.Message, 'error');
                            } else {
                                swal('删除成功', '该信息已被你永久删除', 'success');
                                loadList();
                            }
                        });
                }
            });


            //弹窗的保存操作
            $('#addModuleBtn').click(function () {
                if (!CheckDataValid('.form-horizontal')) {
                    return false;
                }
                if (Y.checkNull($("input[type=radio]:checked").val())) {
                    swal('请选择一个尺码长度', '', 'error');
                    return false;
                }
                var action = "";
                var successText = "";
                if (IsCreate) {
                    action = "Insert";
                    successText = '新增成功';
                }
                else {
                    action = "Update";
                    successText = '编辑成功';
                }

                var sizeList = [];
                $('tr#myTbTr td input[type=radio]:checked').parent().parent().find(".form-control").each(function () {
                    if ($(this).val() != '') {
                        var tmp = {};
                        tmp.MinQty = $(this).val();
                        tmp.SizeID = $(this).attr('data-id');
                        tmp.SizeName = $(this).attr('data-name');
                        tmp.ModelID = $(this).attr('data-modelid');
                        tmp.SizeTypeFlag = $(this).attr('data-sizeTypeFlag');
                        tmp.SizeLength = $("input[type=radio]:checked").val();
                        tmp.OldSizeLength = $("#OldSizeLength").val();
                        sizeList.push(tmp);
                    }
                });

                layer.msg('玩命加载中……', { icon: 16, shade: 0.5, time: 0, maxWidth: 200 });
                Y.API2('PlanningOrderQuantity', action, {
                    OldShopCode: $('#OldShopCode').val(),
                    OldMaterialID: $('#OldMaterialID').val(),
                    Flag: flag,
                    ShopCode: $('#ShopCode').val(),
                    ShopID: $('#ShopID').val(),
                    MaterialID: $('#MaterialID').val(),
                    TotalQty: $('#TotalQty').val(),
                    SizeList: sizeList
                }, function (data) {
                    layer.closeAll('dialog');
                    if (data.Success == false) {
                        swal(data.Message, '', 'error');
                    } else {
                        swal(successText, '', 'success');
                        //关闭新建  or 编辑框
                        $('#closeAddBox').click();
                        //刷新列表
                        loadList();
                    }
                });
            });

            //导入
            $(".btns-container").on("click", '#importBtn', function () {
                $.ImportExcelTemplate({
                    filetype: ['NEWPLANNINGORDERQUANTITY', 'PLANORDERQUANTITY'],
                    filename: [
                        { name: '企划订单量计算', state: null },
                        { name: '配货企划订单量', state: null }
                    ],
                    action: 'ImportTemplate',
                    after: function () {
                        //回调方法
                        loadList();
                    }
                });
            });

            //查询获取尺码
            $("#SearchSize").click(function () {
                var MaterialID = $("#MaterialID").val();
                var ShopCode = $("#ShopCode").val();
                getSizeList(MaterialID, ShopCode);
            });

            loadList();

            /*
            $('#search-store').boxDrop({ width: 120 });
            $('search-store').on("boxdrop-open", function () {
                $('#search-store').boxDrop("load", { ParentAreaID: $("#search-commodity").val(), ProID: $("#serarch-province").val(), CityID: $("#serarch-city").val() });
            });
            */

            //获取明细
            var loadDetail = function (shopCode, materialID, sizeID, sizeLength) {
                if (shopCode == "") {
                    swal("店铺编码不能为空，请刷新页面重试", '', 'error');
                    return false;
                }
                if (materialID == "") {
                    swal("货号不能为空，请刷新页面重试", '', 'error');
                    return false;
                }
                if (sizeID == "") {
                    swal("尺码不能为空，请刷新页面重试", '', 'error');
                    return false;
                }
                if (sizeLength == "") {
                    swal("尺码长度不能为空，请刷新页面重试", '', 'error');
                    return false;
                }
                layer.msg('玩命加载中……', { icon: 16, shade: 0.5, time: 0, maxWidth: 200 });
                Y.API2('PlanningOrderQuantity', 'GetDetails',
                    {
                        shopCode: shopCode,
                        materialID: materialID,
                        sizeID: sizeID,
                        sizeLength: sizeLength
                    }
                    , function (data) {
                        layer.closeAll('dialog');
                        if (data.Success == false) {
                            swal(data.Message, '', 'error');
                        } else {
                            $('#shopSearch').val(data.ShopName);
                            $('#ShopCode').val(data.ShopCode);
                            $('#OldShopCode').val(data.ShopCode);
                            $('#ShopID').val(data.ShopID);
                            $('#MaterialID').val(data.MaterialID);
                            $('#OldMaterialID').val(data.MaterialID);
                            $('#TotalQty').val(data.TotalQty);
                            $('#OldSizeLength').val(data.SizeLength);
                            $("#SearchSize").trigger("click");
                        }
                    });
            }
        });




    </script>
</asp:Content>
